import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import postCssPxToRem from "postcss-pxtorem"

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  server: {
    open:true,
    proxy: {
      "/163api": {
        target: 'https://m.you.163.com',
        changeOrigin: true,
        rewrite(path) {
          console.log(path);
          return path.slice(7)
        }
      },
      "/sphapi": {
        target: 'http://gmall-h5-api.atguigu.cn',
        // target: 'http://sph-h5-api.atguigu.cn',
        changeOrigin: true,
        rewrite(path) {
          return path.slice(7)
        },
      }
    }
  },
  css: {
    postcss: {
      plugins: [
        postCssPxToRem({
          rootValue: 37.5, // 1rem的大小
          propList: ['*'], // 需要转换的属性，这里选择全部都进行转换
        })
      ]
    }
  },
})
